_Pragma("once");

#include <log4c.h>
#include <cstdarg>

#include "LoggerBase.h"



struct Log4cInitializer {
    Log4cInitializer() {
       log4c_init();//int ret =
    }

    ~Log4cInitializer() {
        log4c_fini();
    }

};



template <>
class Logger<LoggerImplement::IMP_BY_LOG4C> {
public:
    Logger(const char* name);
    /** Default destructor */
    virtual ~Logger() {

    }

    enum LogLevel : int {
        FATAL = LOG4C_PRIORITY_FATAL,
        ALERT = LOG4C_PRIORITY_ALERT,
        CRIT = LOG4C_PRIORITY_CRIT,
        ERROR = LOG4C_PRIORITY_ERROR,
        WARN = LOG4C_PRIORITY_WARN,
        NOTICE = LOG4C_PRIORITY_NOTICE,
        INFO = LOG4C_PRIORITY_INFO,
        DEBUG = LOG4C_PRIORITY_DEBUG,
        TRACE = LOG4C_PRIORITY_TRACE,
        NOTSET = LOG4C_PRIORITY_NOTSET,
        UNKNOWN = LOG4C_PRIORITY_UNKNOWN,
    };



    void log(LogLevel level, const char* format, ...) {
        if (log4c_category_is_priority_enabled(mpcategory, level)) {
            std::va_list va;
            va_start(va, format);
            log4c_category_vlog(mpcategory, level, format, va);
            va_end(va);
        }
    }
protected:

    const log4c_category_t* mpcategory;
};




